线结构光视觉传感器/线激光深度传感器标定工具 |
您所在的位置:网站首页 › 线扫激光 传感器 › 线结构光视觉传感器/线激光深度传感器标定工具 |
续集:线结构光视觉传感器/线激光深度传感器标定工具(续) https://jah10527.github.io/articles/lineLaser.html
线结构光视觉系统有着结构简单、使用灵活、受周围光照环境影响小等一系列特点,在实际中得到广泛的应用。在该技术的使用中,标定是避免不了的一个环节。线结构光的标定过程大概可以分为两个部分:相机标定和线结构光标定。目前相机标定技术比较成熟,尤其是以张正友平面标定法为代表的相机标定方法,得到了广泛的应用和认可。而线结构光的标定方法,目前也有一些标定方法在实际中应用。
本人在学习和工作中对线结构光视觉系统的标定进行了研究和编程实现,目前完成了一个基于matlab 2015a的线结构光标定程序。该程序只需要使用一块棋盘格标定板即可完成线结构光视觉系统的标定。下面是该标定软件的具体使用过程。
首先选择用于标定的图片所在的文件夹,然后点击标定按钮,软件将会自动完成相机标定和线结构光标定,并把标定结果存于txt文件中。
相机参数 [456.835948 0 319.163600 0 455.503272 224.297494 0 0 1] 畸变系数 [-0.428655 0.240668 0.000222 -0.000840 -0.074862] 平均重投影误差 0.148146pixel 线结构光参数 [0.996652 0.009722 0.081176 135.203206]
附源码地址(.p文件) http://download.csdn.net/detail/j10527/9694703
部分代码: 1.相机标定按钮代码 % --- Executes on button press in camera_calibration. function camera_calibration_Callback(hObject, eventdata, handles) % hObject handle to camera_calibration (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) disp 'Camera calibration begin...'; images = imageSet(get(handles.dir_cam, 'String')); % images = imageSet('robart'); imageFileNames = images.ImageLocation; for k = 1:length(imageFileNames) im = imread(imageFileNames{k}); if size(im,3)==3 im=rgb2gray(im); end im = imadjust(im); imwrite(im,imageFileNames{k}); end % Detect calibration pattern. [imagePoints, boardSize] = detectCheckerboardPoints(imageFileNames); % Generate world coordinates of the corners of the squares. % squareSize = 10; % millimeters squareSize = str2num(get(handles.square_size, 'String')); worldPoints = generateCheckerboardPoints(boardSize, squareSize); % Calibrate the camera. [params, ~, ~] = estimateCameraParameters(imagePoints, worldPoints, ... 'EstimateTangentialDistortion', true, 'NumRadialDistortionCoefficients', 3); if get(handles.show, 'value') figure;subplot(2,1,1); showReprojectionErrors(params); end for k = 1:size(imagePoints,3) % im = imread(imageFileNames{k}); % im = rgb2gray(im); % J = undistortImage(im, params); % imwrite(J,['undistorted_calib/im' num2str(k) '.jpg']); err(k) = norm(mean(abs(params.ReprojectionErrors(:,:,k)),1)); end for k = 1:round(size(imagePoints,3)*0.3) [~,ind]=max(err); err(ind)=[]; imagePoints(:,:,ind)=[]; end % [imagePoints, boardSize] = detectCheckerboardPoints(imageFileNames); % Calibrate the camera. [params, ~, ~] = estimateCameraParameters(imagePoints, worldPoints, ... 'EstimateTangentialDistortion', true, 'NumRadialDistortionCoefficients', 3); if get(handles.show, 'value') subplot(2,1,2); showReprojectionErrors(params); figure; showExtrinsics(params, 'CameraCentric'); end dir_str = get(handles.dir_str, 'String'); images = imageSet(dir_str); system('mkdir undistorted_stripe'); delete undistorted_stripe/* for k = 1:images.Count I = imread(images.ImageLocation{k}); [J,newOrigin] = undistortImage(I,params,'OutputView', 'same'); % if get(handles.show, 'value') % figure; % imshow(J); % end imwrite(J,['undistorted_stripe/im_stripe' num2str(k) '.jpg']); end % images = imageSet('pics_raw/'); % for k = 1:images.Count % I = imread(images.ImageLocation{k}); % [J,newOrigin] = undistortImage(I,params,'OutputView', 'same'); % figure; % imshow(J); % imwrite(J,['pics/im_' num2str(k) '.jpg']); % end fd = fopen('cam_paras.txt', 'w+'); fprintf(fd, '%f %f %f %f\n', params.IntrinsicMatrix(1), params.IntrinsicMatrix(3), ... params.IntrinsicMatrix(5), params.IntrinsicMatrix(6)); fprintf(fd, '%f %f %f %f %f\n', params.RadialDistortion(1), params.RadialDistortion(2),... params.TangentialDistortion(1), params.TangentialDistortion(2), params.RadialDistortion(3)); fprintf(fd, '%f\n', params.MeanReprojectionError(1)); fclose(fd); disp 'Camera calibration done.'; disp 'Camera calibration results were saved in cam_paras.txt.';
stripe_paras.txt文件按照如下代码保存的:
基于qt5和opencv3的新版本可执行文件,下载地址 https://github.com/jah10527/laserLineToolkit
上面只显示了Z坐标,X,Y未显示在界面上。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |